package com.tdkj.service.shop.impl;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.tdkj.dao.shop.IBeanShopRecommendationTypeDao;
import com.tdkj.model.shop.BeanShopRecommendationType;
import com.tdkj.service.BaseService;
import com.tdkj.service.shop.IBeanShopRecommendationTypeService;

@Component
public class BeanShopRecommendationTypeServiceImpl extends BaseService
		implements IBeanShopRecommendationTypeService {

	private IBeanShopRecommendationTypeDao beanShopRecommendationTypeDao;

	/**
	 * @param beanShopRecommendationCustomDao the beanShopRecommendationCustomDao to set
	 */
	@Resource
	public void setBeanShopRecommendationTypeDao(
			IBeanShopRecommendationTypeDao beanShopRecommendationTypeDao) {
		this.beanShopRecommendationTypeDao = beanShopRecommendationTypeDao;
	}
	
	@Override
	public List<BeanShopRecommendationType> getAll() {
		List<BeanShopRecommendationType> beans = beanShopRecommendationTypeDao.findAll(BeanShopRecommendationType.class);
		if(beans==null || beans.size()==0){
			beans = (beans==null)? new ArrayList<BeanShopRecommendationType>() : beans;
			
			BeanShopRecommendationType bean1 = new BeanShopRecommendationType();
			bean1.setName("网站首页旺铺推荐（12个位置）");
			bean1.setQuantity(12);
			bean1.setLeftQuantity(12);
			
			
			BeanShopRecommendationType bean2 = new BeanShopRecommendationType();
			bean2.setName("商城首页旺铺推荐（6个位置）");
			bean2.setQuantity(6);
			bean2.setLeftQuantity(6);
			
			BeanShopRecommendationType bean3 = new BeanShopRecommendationType();
			bean3.setName("次页旺铺推荐");
			bean3.setQuantity(6);
			bean3.setLeftQuantity(6);
			
			beanShopRecommendationTypeDao.save(bean1);
			beanShopRecommendationTypeDao.save(bean2);
			beanShopRecommendationTypeDao.save(bean3);
			
			beans.add(bean1);
			beans.add(bean2);
			beans.add(bean3);
		}
		
		return beans;
	}

}
